package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;*/

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.EconomicTypeDao;
import com.hy.erp.inventory.dao.interfaces.IEconomicTypeDao;
import com.hy.erp.inventory.pojo.EconomicType;
import com.hy.erp.inventory.pojo.interfaces.IEconomicType;
import com.hy.erp.inventory.service.interfaces.IEconomicTypeService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:18:15</li>
 * <li>类型名称：EconomicTypeService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "economicTypeService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless*/
@Component("economicTypeService")
public class EconomicTypeService  extends AbstractBusinessService < EconomicTypeDao > implements IEconomicTypeService{

	private IEconomicTypeDao economicTypeDao=null;
	

	@Resource(name="economicTypeDao")
	public void setEconomicTypeDao(EconomicTypeDao economicTypeDao) {
		this.economicTypeDao = economicTypeDao;
	}
	@Override
	public boolean addEconomicType(EconomicType economicType) {





		if ( null == economicType)
		{
			return true ;
		}
		
		else
		{
			//System.out
			//			.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


		//	IEconomicTypeDao economicTypeDao =
			//                       ( IEconomicTypeDao ) this
			//                                         .getDao ( IEconomicType.class ) ;
			
			return economicTypeDao
			                .persist ( economicType ) ;
		}
		
	
	
	
	
	
	}

	@Override
	public boolean modifyEconomicType(EconomicType economicType) {





		if ( ( null == economicType )
			     || ( null == economicType
			                                .getIdentifier ( ) )
			     || ( economicType
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

			//	IEconomicTypeDao economicTypeDao =
				//                       ( IEconomicTypeDao ) this
				//                                          .getDao ( IEconomicType.class ) ;

		
					
				if ( null == economicType )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (economicTypeDao
				                  .merge ( economicType ) != null ) ;
			}
		
	
	
	
	
	
	}

	@Override
	public Integer removeEconomicType(String[] economicTypeIds) {





		if ( ( null == economicTypeIds)
			     || ( economicTypeIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{



				//IEconomicTypeDao economicTypeDao =
                //    ( IEconomicTypeDao ) this
                //                       .getDao ( IEconomicType.class ) ;


		

				return economicTypeDao
				                .remove ( economicTypeIds ) ;
			}
	
	
	
	
	
	}

	@ Override
	public String [ ] addEconomicType (
										Object [ ] economicType )
	{

		if ( null == economicType)
		{
			return null ;
		}
		
		else
		{
			
			//IEconomicTypeDao economicTypeDao =
			//                       ( IEconomicTypeDao ) this
			//                                          .getDao ( IEconomicType.class ) ;

			EconomicType[] economicTypes=new EconomicType[economicType.length];
						for(int i=0;i<economicType.length;i++)
						{
							EconomicType economicType2=( EconomicType ) economicType[i];
							economicTypes[i]=economicType2;
						}
						return economicTypeDao
						                .persist ( economicTypes ) ;
			
			
		}
		
	
	
	
	
	}

	@ Override
	public List <EconomicType > getAllEconomicType ( )
	{
		//IEconomicTypeDao economicTypeDao =
       //     ( IEconomicTypeDao ) this
        //                       .getDao ( IEconomicType.class ) ;

		return economicTypeDao
		                .find ( ) ;
	}

	@ Override
	public String [ ] modifyEconomicType (
											Object [ ] economicType )
	{


		if ( null == economicType)
		{
			return null ;
		}
		
		else
		{
			
			//IEconomicTypeDao economicTypeDao =
		//	                       ( IEconomicTypeDao ) this
		//	                                          .getDao ( IEconomicType.class ) ;

			EconomicType[] economicTypes=new EconomicType[economicType.length];
						for(int i=0;i<economicType.length;i++)
						{
							EconomicType economicType2=( EconomicType ) economicType[i];
							economicTypes[i]=economicType2;
						}
						return economicTypeDao
						                .merge ( economicTypes ) ;
			
			
		}
		
	
	
	
	
	
	}

}
